/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "HORARIO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Horario.findAll", query = "SELECT h FROM Horario h"),
    @NamedQuery(name = "Horario.findByModgCod", query = "SELECT h FROM Horario h WHERE h.horarioPK.modgCod = :modgCod"),
    @NamedQuery(name = "Horario.findByDiaCod", query = "SELECT h FROM Horario h WHERE h.horarioPK.diaCod = :diaCod"),
    @NamedQuery(name = "Horario.findByHorIni", query = "SELECT h FROM Horario h WHERE h.horIni = :horIni"),
    @NamedQuery(name = "Horario.findByHorFin", query = "SELECT h FROM Horario h WHERE h.horFin = :horFin")})
public class Horario implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HorarioPK horarioPK;
    @Column(name = "HOR_INI")
    @Temporal(TemporalType.TIME)
    private Date horIni;
    @Column(name = "HOR_FIN")
    @Temporal(TemporalType.TIME)
    private Date horFin;
    @JoinColumn(name = "MODG_COD", referencedColumnName = "MODG_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ModuloGrupo moduloGrupo;
    @JoinColumn(name = "DIA_COD", referencedColumnName = "DIA_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Dia dia;
    @JoinColumn(name = "AUL_COD", referencedColumnName = "AUL_COD")
    @ManyToOne(fetch = FetchType.LAZY)
    private Aula aulCod;

    public Horario() {
    }

    public Horario(HorarioPK horarioPK) {
        this.horarioPK = horarioPK;
    }

    public Horario(String modgCod, int diaCod) {
        this.horarioPK = new HorarioPK(modgCod, diaCod);
    }

    public HorarioPK getHorarioPK() {
        return horarioPK;
    }

    public void setHorarioPK(HorarioPK horarioPK) {
        this.horarioPK = horarioPK;
    }

    public Date getHorIni() {
        return horIni;
    }

    public void setHorIni(Date horIni) {
        this.horIni = horIni;
    }

    public Date getHorFin() {
        return horFin;
    }

    public void setHorFin(Date horFin) {
        this.horFin = horFin;
    }

    public ModuloGrupo getModuloGrupo() {
        return moduloGrupo;
    }

    public void setModuloGrupo(ModuloGrupo moduloGrupo) {
        this.moduloGrupo = moduloGrupo;
    }

    public Dia getDia() {
        return dia;
    }

    public void setDia(Dia dia) {
        this.dia = dia;
    }

    public Aula getAulCod() {
        return aulCod;
    }

    public void setAulCod(Aula aulCod) {
        this.aulCod = aulCod;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (horarioPK != null ? horarioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Horario)) {
            return false;
        }
        Horario other = (Horario) object;
        if ((this.horarioPK == null && other.horarioPK != null) || (this.horarioPK != null && !this.horarioPK.equals(other.horarioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Horario[ horarioPK=" + horarioPK + " ]";
    }
    
}
